﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Inventory_ViewInventory : System.Web.UI.Page
{
    const int idxID = 0;
    const int idxCode = 1;
    const int idxName = 2;
    const int idxQuantity = 3;
    const int idxinoutQuantity = 4;


    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void ButtonFind_Click(object sender, EventArgs e)
    {
        Parameter sorting = ObjectDataSource_Inventory.SelectParameters["orderby"];
        Parameter code = new Parameter("productcode",ObjectDataSource_Inventory.SelectParameters["productcode"].Type,this.TextBoxFindCode.Text.Trim());
        ObjectDataSource_Inventory.SelectParameters.Clear();
        ObjectDataSource_Inventory.SelectParameters.Add(code);
        ObjectDataSource_Inventory.SelectParameters.Add(sorting);
        GridViewInventory.DataBind();
    }
    protected void DrpProductTypeList_SelectedIndexChanged(object sender, EventArgs e)
    {
        Parameter sorting = ObjectDataSource_Inventory.SelectParameters["orderby"];
        Parameter code = new Parameter("productcode", ObjectDataSource_Inventory.SelectParameters["productcode"].Type, DrpProductTypeList.SelectedValue.Trim());
        ObjectDataSource_Inventory.SelectParameters.Clear();
        ObjectDataSource_Inventory.SelectParameters.Add(code);
        ObjectDataSource_Inventory.SelectParameters.Add(sorting);
        GridViewInventory.DataBind();
    }

    protected void ButtonWarehouseList_Click(object sender, EventArgs e)
    {
        Response.Redirect("WarehouseList.aspx");
    }
    protected void ButtonDeliveredSheet_Click(object sender, EventArgs e)
    {
        Response.Redirect("DeliveredSheet.aspx");
    }

    protected void ButtonHistory_Click(object sender, EventArgs e)
    {
        Response.Redirect("WarehouseHistory.aspx");
    }
    protected void GridViewInventory_Sorting(object sender, GridViewSortEventArgs e)
    {
        ObjectDataSource_Inventory.SelectParameters["orderby"].DefaultValue = e.SortExpression;
        GridViewInventory.DataBind();
        e.Cancel = true;        
    }
}
